package com.geodroid.euclidian;

import android.graphics.RectF;

import com.geodroid.android.graphics.LineF;

public class SegmentF extends LineF {
	public float startX, startY,stopX,stopY ;

	/**
	 * @param a
	 * @param b
	 * @param c
	 * @param startX
	 * @param startY
	 * @param stopX
	 * @param stopY
	 */
	public SegmentF(float startX, float startY,
			float stopX, float stopY) {
		super(startY - stopY,stopX - startX,startX*stopY - startY*stopX ) ;
		this.startX = startX;
		this.startY = startY;
		this.stopX = stopX;
		this.stopY = stopY;
	}

	public SegmentF() {
		// TODO Auto-generated constructor stub
		super();
	}

	public void set(float startX, float startY,	float stopX, float stopY){
		this.startX = startX;
		this.startY = startY;
		this.stopX = stopX;
		this.stopY = stopY;
		a = startY - stopY ;
		b =  stopX - startX ; 
		c = startX*stopY - startY*stopX ;
	}

	public boolean intersect(RectF r){
		return (startX<stopX&& startX<=r.right && stopX>=r.left && super.intersect(r)) 
				||
				(startX>=r.left && stopX<=r.left && super.intersect(r))
				;
	}
	 
	
}
